package com.koomii.redis.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.koomii.redis.demo.message.sender.DemoRedisSender;


@Controller
public class MessageTestController {
	@Autowired
	DemoRedisSender demoRedisSender;
	
	@RequestMapping("/message/send")
	@ResponseBody
	public String sendMessage(String topic,String msg) {
		try {
			if(topic == null || topic == "") {
				topic = "TEST";
			}
			if(msg == null || msg == "") {
				msg = "NO MESSAGE";
			}
			demoRedisSender.send(topic,msg);
			return "success:";
		} catch (Exception e) {
			e.printStackTrace();
			return "fail";
		}
	}
}
